import Vue from 'vue';
import Router from 'vue-router';

const _import = require('./_import_' + process.env.NODE_ENV);
// 主页子路由
let homeroutes = [{
  path: 'productlist',
  name: 'productlist',
  component: _import('productlist/index')
},
  {
    path: 'orderConfirm',
    name: 'orderConfirm',
    component: _import('orderConfirm/index')
  }];

// 导航子路由
let navbarroutes = [{
  path: 'home',
  name: 'home',
  component: _import('home/index'),
  children: homeroutes
  },
  {
    path: 'orders',
    name: 'orders',
    component: _import('orders/orders')
  },
  {
    path: 'account',
    name: 'account',
    component: _import('account/account')
  }];

// 根路由
let routes = [
  {
    path: '/404',
    name: 'error',
    component: _import('error/404')
  },
  {
    path: '/error',
    name: 'customerror',
    component: _import('error/customError')
  },
  {
    path: '/',
    name: 'app',
    component: _import('shell/shell'),
    children: navbarroutes
  }
];

Vue.use(Router);
let router = new Router({
  'linkActiveClass': 'active',
  mode: 'history',
  base: __dirname,
  routes
});

export default router;
